<?php

class TestController extends ProjectController
{
	public $layout = "//layouts/blank";
	public function actionIndex()
	{
		
		$t = file_get_contents('upload/zipcode.csv');
		$a = explode("\n",$t);
		$tx = "";
		$n = 7000;
		foreach($a as $key=>$value){
			
			if($key>0){
				$n++;
				$value = trim($value);
				$e = explode(",",$value);
				if(!empty($e[0]) && !empty($e[1]) && !empty($e[2]) && !empty($e[3]) && !empty($e[4]) && !empty($e[5]))
					$tx.= "INSERT INTO `zipcodes` VALUES ($n,'".$e[0]."', '".$e[1]."', '".$e[2]."', '".$e[3]."', '".$e[4]."', '".$e[5]."'); \n";
				
			}
			// INSERT INTO `zipcodes` VALUES ('1', 'A0E 2Z0', 'Monkstown', 'NL', '48', '-55', 'ca');
		}
		file_put_contents('upload/a.sql',$tx);
		// echo $tx;
	}

	
	
}
